package com.ajk.server.bkcontroller;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ajk.server.controller.events.RedisSyncEvent;
import com.ajk.server.model.response.Result;
import com.ajk.server.utils.SpringContextUtil;

@RequestMapping("/admin/redis/sync")
@RestController
public class AdminRedisSyncController {
	
	@RequestMapping("/one/{type}/{sourceId}")
	public Result flushOneReids(@PathVariable("type") Integer type, @PathVariable("sourceId") Integer sourceId){
		RedisSyncEvent event = new RedisSyncEvent(sourceId, type);
		SpringContextUtil.getApplicationContext().publishEvent(event);
		return new Result();
	}
	
	@RequestMapping("/bytype/{type}")
	public Result flushOneReids(@PathVariable("type") Integer type){
		RedisSyncEvent event = new RedisSyncEvent(this, type);
		SpringContextUtil.getApplicationContext().publishEvent(event);
		return new Result();
	}
	
	

}
